package trunk.trunk.besteAukera;

import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;

public class DBiegonkorra extends Sekuentzialak{
	private Color kolorea;
	private Vector<Hanka> hankaBektorea=new Vector<Hanka>();
	private Vector<Hanka> sarreraBektorea=new Vector<Hanka>();
	private Hanka s1, s2, i1,i2,s3;
	public DBiegonkorra(int x1, int y1, int hankaKop, int sarreraKopMax, String mota) {
		super(x1, y1, hankaKop, sarreraKopMax, mota);
		// TODO Auto-generated constructor stub
	
	s1 = new Hanka(x-20, y+40, "positiboa", "s", 0, this, "h","ez");
	
	
	s2 = new Hanka(x+30 , y-20 , "negatiboa", "s", 1, this, "b","ez");
	s3 = new Hanka(x+30 , y+100 , "negatiboa", "s", 2, this, "b","bai");
	i1 = new Hanka(x+80 , y +28, "positiboa", "i", 3, this, "h","ez");
	i2 = new Hanka(x+80 , y+52 , "negatiboa", "i", 4, this, "h","ez");
	
	lotList[0]=s1;
	lotList[1]=s2;
	lotList[2]=s3;
	
	lotList[3]=i1;
	lotList[4]=i2;
	
}
public void dibujate(Graphics g) {


	g.setColor(Color.black);
	//goikoa
	g.drawLine(x, y,x+60, y);
	//beikoa
	g.drawLine(x+60, y ,x+60, y +80);
	//ezkerretakoa
	g.drawLine(x+60, y+80, x, y + 80);
	//eskubitakoa
	g.drawLine(x, y+80, x, y );
	
	g.drawLine(x-10, y+75, x, y+75);
	g.drawLine(x-10, y+85, x-10, y+75);
	g.drawString(">", x, y+80);

	g.drawString("D", x+2, y+43);
	
	g.drawString("PR*.L", x+15, y+12);
	g.drawString("Q", x+50, y+33);
	g.drawString("Q.L", x+40, y+55);

	g.drawString("CL*.L", x+15, y+78);
		s1.dibujate(g);
		s2.dibujate(g);
		i1.dibujate(g);
		i2.dibujate(g);
		
		s3.dibujate(g);
		
}
public boolean estaDentro(int x, int y) {
	if ((x > this.x) && (x < (this.x + 60)) && (y > this.y)
			&& (y < (this.y + 80))) {
		return true;
	}
	return false;

}
public void setPosicion(int x1, int y1) {
	this.x = x1;
	this.y = y1;
}

public int getX() {
	return x;
}
public int getY() {
	return y;
}
@Override
public void funtzioLogikoa(Integer... values) {
	
	// TODO Auto-generated method stub
	if((s2.getSarrera().getBalioa()==0)&&(s3.getSarrera().getBalioa()==1)){
		lotList[3].getIrteera().setBalioa(0);
		lotList[4].getIrteera().setBalioa(0);
	}
	if((s2.getSarrera().getBalioa()==1)&&(s3.getSarrera().getBalioa()==0)){
		lotList[3].getIrteera().setBalioa(1);
		lotList[4].getIrteera().setBalioa(1);
	}
	
	if((s2.getSarrera().getBalioa()==0)&&(s3.getSarrera().getBalioa()==0)&&(s1.getSarrera().getBalioa()==0)){
		lotList[3].getIrteera().setBalioa(0);
		lotList[4].getIrteera().setBalioa(0);
	}
	if((s2.getSarrera().getBalioa()==0)&&(s3.getSarrera().getBalioa()==0)&&(s1.getSarrera().getBalioa()==1)){
		lotList[3].getIrteera().setBalioa(1);
		lotList[4].getIrteera().setBalioa(1);
	}
	
	
		
		
	
}
@Override
public Vector<Hanka> getHankak() {
	// TODO Auto-generated method stub
	hankaBektorea = new Vector<Hanka>();
	hankaBektorea.addElement(s1);
	hankaBektorea.addElement(s2);
	hankaBektorea.addElement(s3);

	hankaBektorea.addElement(i1);
	hankaBektorea.addElement(i2);

	return hankaBektorea;
}

@Override
public Hanka getIrteeraHanka() {
	// TODO Auto-generated method stub
	return null;
}

@Override
public Vector<Hanka> getSarreraHankak() {
	// TODO Auto-generated method stub
	sarreraBektorea=new Vector<Hanka>();
	sarreraBektorea.addElement(s1);
	sarreraBektorea.addElement(s2);
	sarreraBektorea.addElement(s3);

	return sarreraBektorea;
}
public Integer not(Integer sar){
if (sar==0)
	return 1;
else return 0;
}
	}


